<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page isELIgnored="false" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">

    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css"/>

</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 软件审核管理 <span
        class="c-gray en">&gt;</span>申请列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                             href="javascript:location.replace(location.href);" title="刷新"
                                             id="refresh"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>

<div class="page-container">
    <div class="mt-20">
        <table class="table table-border table-bordered table-hover table-bg table-sort">
            <thead>
            <tr class="text-c">
                <th width="100">ID</th>
                <th width="300">上传者</th>
                <th width="100">名称</th>
                <th width="150">申请时间</th>
                <th width="100">软件分类</th>
                <th>小图标</th>
                <th>中图标</th>
                <th width="100">查看</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach var="data" items="${dataMap}">
                <tr class="text-c">
                    <td>${data[0]}</td>
                    <td><a href="#"
                           onclick="lookInfo('开发者详情','/accountAdmin/admin/accountInfo?id=${data[1]}')">${data[1]}</a>
                    </td>
                    <td>
                        <a href="#"
                           onclick="lookInfo('软件详情','/SoftwareAdmin/admin/softInfo?id=${data[0]}')">${data[2]}</a>
                    </td>
                    <td><fmt:formatDate value="${data[3]}" pattern="yyyy-MM-dd HH:mm"/></td>
                    <td>${data[4]}</td>
                    <td><img width="100" height="100"
                             src="/massageExamineAction/admin/lookIcon?rid=${data[0]}&&type=minImage"></td>
                    <td><img width="100" height="100"
                             src="/massageExamineAction/admin/lookIcon?rid=${data[0]}&&type=medImage"></td>
                    <td>
                        <a href="/massageExamineAction/admin/InputBigIcon?id=${data[0]}&&type=bigImage">查看截图</a>&nbsp;&nbsp;<a
                            href="/massageExamineAction/admin/downloadApk?md5=${data[5]}">下载</a></td>


                    <td><a title="通过" href="javascript:;" class="ml-5"
                           style="text-decoration:none" onclick="passApk('${data[0]}',1)"><i
                            class="Hui-iconfont">&#xe6e1;</i></a><a title="拒绝"
                                                                    href="javascript:;" class="ml-5"
                                                                    style="text-decoration:none"
                                                                    onclick="passApk('${data[0]}',-1)"><i
                            class="Hui-iconfont">&#xe6dd;</i></a></td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
</div>

<!--弹窗拒绝原因-->
<div id="modal-demo" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content radius">
            <div class="modal-header">
                <h3 class="modal-title">请选择不通过原因</h3>
                <a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:;">×</a>
            </div>
            <div class="modal-body">
                <form class="form form-horizontal">
                    <div class="row cl">
                        <div class="formControls col-xs-1 col-sm-1">
                            <input name="contents" type="checkbox" id="contents1" value="有广告">
                        </div>
                        <label class="form-label col-xs-3 col-sm-3" for="contents1">有广告</label>

                        <div class="formControls col-xs-1 col-sm-1">
                            <input name="contents" type="checkbox" id="contents2" value="图片不全">
                        </div>
                        <label class="form-label col-xs-3 col-sm-3" for="contents2">图片不全</label>

                        <div class="formControls col-xs-1 col-sm-1">
                            <input name="contents" type="checkbox" id="contents3" value="软件包出错">
                        </div>
                        <label class="form-label col-xs-3 col-sm-3" style=" text-align: left;margin-left: -18px;"
                               for="contents3">软件包出错</label>

                    </div>
                    <div class="row cl">
                        <label class="form-label col-xs-5 col-sm-3 form-label_1"><span
                                class="c-red">*</span>其他原因描述：</label>
                        <div class="formControls col-xs-7 col-sm-8">
                            <textarea class="textarea" name="contents" required id="content"
                                      placeholder="详细原因"></textarea>

                        </div>

                    </div>
                </form>
            </div>
            <span id="id" hidden></span>
            <div class="modal-footer">
                <button class="btn btn-primary" onclick="refuseApply()">确定</button>
                <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
            </div>
        </div>
    </div>
</div>
<!--[if lt IE 9]>
<script type="text/javascript" src="/admin/lib/html5shiv.js"></script>
<script type="text/javascript" src="/admin/lib/respond.min.js"></script>
<![endif]-->
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/admin/lib/laypage/1.2/laypage.js"></script>
<script>
    $(function () {
        $('.table-sort').dataTable({
            "aaSorting": [[1, "desc"]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": []
        });

    });

    /*添加-版本*/
    function lookInfo(title, url) {
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }

    function passApk(id, state) {
        var tip = ""
        if (state == 1) {
            tip = '你确定通过该软件的审核么？';
            layer.confirm(tip, function (index) {
                $.post('/massageExamineAction/admin/passApk', {id: id, state: state}, function (data) {
                    if (data.valueOf() == "true") {
                        location.replace(location.href);
                    } else {
                        layer.msg('通过失败', {icon: 1, time: 1000});
                    }
                });
            });
        } else if (state == -1) {
            $("#modal-demo").modal("show");
            $("#id").text(id);
        }

    }

    function refuseApply() {
        var temp = 0
        var value = "";
        $(".modal-body input[name='contents']:checked").each(function (index, elem) {
            console.log(index);
            value += index + 1 + ":" + $(elem).val() + ",";
            temp = index + 2;
        });
        value += temp + ":" + $("#content").val();
        var tip = '你确定拒绝该软件通过吗？';
        layer.confirm(tip, function (index) {
            var id = $("#id").text();
            var state = -1;
            $.post('/massageExamineAction/admin/passApk', {
                id: id,
                state: state,
                contents: value
            }, function (data) {
                if (data.valueOf() == "true") {
                    location.replace(location.href);
                } else {
                    layer.msg('拒绝失败', {icon: 1, time: 1000});
                }

            });
        });
    }
</script>
</body>
</html>